﻿//-----------------------------------------------------------------------
// <copyright file="UIBasedSettingsProvider.cs" author="Artak Mkrtchyan">
//     Creative Commons - GNU General Public License (http://creativecommons.org/licenses/GPL/2.0/
// </copyright>
// <author>Artak Mkrtchyan</author>
// <email>mkArtak@gmail.com</email>
// <date>02/05/2013</date>
//-----------------------------------------------------------------------

using ConsoleHoster.Common.Utilities;
using ConsoleHoster.Common.Utilities.Threading;
using System;
using System.Windows;

namespace ConsoleHoster.Common.Model
{
	public abstract class UIBasedSettingsProvider<T> : IUserDataRequester where T : Window
	{
		private readonly ILogger logger;
		private readonly IDispatcher dispatcher;
		private readonly ViewSettings viewSettings;
		protected T view;

		protected UIBasedSettingsProvider(IDispatcher argDispatcher, ViewSettings argViewSettings, ILogger argLogger)
		{
			if (argDispatcher == null)
			{
				throw new ArgumentNullException("argDispatcher");
			}
			if (argViewSettings == null)
			{
				throw new ArgumentNullException("argViewSettings");
			}

			this.dispatcher = argDispatcher;
			this.viewSettings = argViewSettings;
            this.logger = argLogger ?? EmptyLogger.Instance;
		}

		public Window View
		{
			get
			{
				return this.view;
			}
		}

		protected ILogger Logger
		{
			get
			{
				return this.logger;
			}
		}

		protected IDispatcher Dispatcher
		{
			get
			{
				return this.dispatcher;
			}
		}

		protected ViewSettings ViewSettings
		{
			get
			{
				return this.viewSettings;
			}
		}
	}
}
